package com.ruoyi.web.controller.mf178;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.mf178.domain.UpdateGoodSupplierService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mf178.domain.Mf178SupplyGood;
import com.ruoyi.mf178.service.IMf178SupplyGoodService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * mf178Controller
 *
 * @author ruoyi
 * @date 2025-07-14
 */
@RestController
@RequestMapping("/mf178sys/good")
public class Mf178SupplyGoodController extends BaseController {
    @Autowired
    private IMf178SupplyGoodService mf178SupplyGoodService;

    /**
     * 查询mf178列表
     */
    @PreAuthorize("@ss.hasPermi('mf178:good:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mf178SupplyGood mf178SupplyGood) {
        startPage();
        List<Mf178SupplyGood> list = mf178SupplyGoodService.selectMf178SupplyGoodList(mf178SupplyGood);
        return getDataTable(list);
    }

    /**
     * 导出mf178列表
     */
    @PreAuthorize("@ss.hasPermi('mf178:good:export')")
    @Log(title = "mf178", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Mf178SupplyGood mf178SupplyGood) {
        List<Mf178SupplyGood> list = mf178SupplyGoodService.selectMf178SupplyGoodList(mf178SupplyGood);
        ExcelUtil<Mf178SupplyGood> util = new ExcelUtil<Mf178SupplyGood>(Mf178SupplyGood.class);
        util.exportExcel(response, list, "mf178数据");
    }

    /**
     * 获取mf178详细信息
     */
    @PreAuthorize("@ss.hasPermi('mf178:good:query')")
    @GetMapping(value = "/{goodsId}")
    public AjaxResult getInfo(@PathVariable("goodsId") Long goodsId) {
        return success(mf178SupplyGoodService.selectMf178SupplyGoodByGoodsId(goodsId));
    }

    /**
     * 新增mf178
     */
    @PreAuthorize("@ss.hasPermi('mf178:good:add')")
    @Log(title = "mf178", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mf178SupplyGood mf178SupplyGood) {
        return toAjax(mf178SupplyGoodService.insertMf178SupplyGood(mf178SupplyGood));
    }

    /**
     * 修改mf178
     */
    @PreAuthorize("@ss.hasPermi('mf178:good:edit')")
    @Log(title = "mf178", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mf178SupplyGood mf178SupplyGood) {
        return toAjax(mf178SupplyGoodService.updateMf178SupplyGood(mf178SupplyGood));
    }

    /**
     * 删除mf178
     */
    @PreAuthorize("@ss.hasPermi('mf178:good:remove')")
    @Log(title = "mf178", businessType = BusinessType.DELETE)
    @DeleteMapping("/{goodsIds}")
    public AjaxResult remove(@PathVariable Long[] goodsIds) {
        return toAjax(mf178SupplyGoodService.deleteMf178SupplyGoodByGoodsIds(goodsIds));
    }

    /**
     * 批量变更商品supplierService
     */
    @PreAuthorize("@ss.hasPermi('mf178:good:edit')")
    @PostMapping("/updateGoodSupplierService")
    public AjaxResult updateGoodSupplierService(@RequestBody UpdateGoodSupplierService updateGood) {
        return toAjax(mf178SupplyGoodService.updateGoodSupplierService(updateGood));
    }
}
